package controller

import (
	"github.com/gin-gonic/gin"
	"go-api/app/global"
	"go-api/app/request"
	"go-api/internal/response"
)

type Example struct {
	G *global.Global
}

func (ex Example) Info() response.ApiHandlerFunc {

	return func(c *gin.Context) (r interface{}, e error) {
		var req request.ExampleRequest
		if err := c.ShouldBindQuery(&req); err != nil {
			e = err
			return
		}

		r = gin.H{
			"name": req.Name,
		}

		//示例业务错误
		//e = berr.NewBusinessCode(berr.UnknownUserCode)

		return
	}
}

func NewExampleController(g *global.Global) *Example {
	return &Example{G: g}
}
